//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#ifndef __ELASTOS_STUBCONTEXT_H__
#define __ELASTOS_STUBCONTEXT_H__
#include <eladef.h>

#if (defined(_KDBAGENT) || defined(_UDBAGENT))

const UInt32 c_uTraceBit = 0x100;
const UInt32 c_uDbgInstructionLen = 1;

typedef enum RegIndex
{
    R0INDEX = 0, R1INDEX, R2INDEX, R3INDEX, R4INDEX, R5INDEX, R6INDEX, R7INDEX,
    R8INDEX, R9INDEX, R10INDEX, R11INDEX, R12INDEX, SPINDEX, LRINDEX, PCINDEX,
    F0INDEX, F1INDEX, F2INDEX, F3INDEX, F4INDEX, F5INDEX, F6INDEX, F7INDEX,
    FPSINDEX, CPSRINDEX
} RegIndexs;

struct StubContext
{
    UInt32 r0, r1, r2, r3;
    UInt32 r4, r5, r6, r7;
    UInt32 r8, r9, r10, r11;
    UInt32 r12, sp, lr, pc;
    UInt32 f0, f1, f2, f3, f4, f5, f6, f7;
    UInt32 fps, cpsr;

#if defined(_UDBAGENT)
    void SetupUdbContext(InterruptContext *pCxt, StubContext *pUdbCxt);
    void RestoreUdbInterruptContext(InterruptContext *pCxt, \
                                    StubContext *pUdbCxt);
#endif // #if defined(_UDBAGENT)

#if defined(_KDBAGENT)
    void SetupKdbContext(InterruptContext *pCxt, StubContext *pKdbCxt);
    void RestoreKdbInterruptContext(InterruptContext *pCxt, \
                                    StubContext *pKdbCxt);
#endif //#if defined(_KDBAGENT)
};

const size_t c_uRegBytes = sizeof(UInt32);
const size_t c_uRegAllBytes = sizeof(StubContext);

#if defined(_KDBAGENT)
void SwitchToKdbStack(UInt32 uKdbStack);
#endif //#if defined(_KDBAGENT)

//#if defined(_UDBAGENT)
// void SwitchToUdbStack(UInt32 uUdbStack);
//#endif //#if defined(_UDBAGENT)

#endif //#if (defined(_KDBAGENT) || defined(_UDBAGENT))

EXTERN void KdbHandler(vector_t vector, InterruptContext *pCxt);

EXTERN void UdbHandler(vector_t vector, InterruptContext *pCxt);

#endif // __ELASTOS_STUBCONTEXT_H__
